/*-------------------------------------------------------------------------
  Author (C) 2008, Charles Wang <charlesw123456@gmail.com>

  This program is free software; you can redistribute it and/or modify it 
  under the terms of the GNU General Public License as published by the 
  Free Software Foundation; either version 2, or (at your option) any 
  later version.

  This program is distributed in the hope that it will be useful, but 
  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  for more details.

  You should have received a copy of the GNU General Public License along 
  with this program; if not, write to the Free Software Foundation, Inc., 
  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

  As an exception, it is allowed to write an extension of Coco/R that is
  used as a plugin in non-free software.

  If not otherwise stated, any source code generated by Coco/R (other than 
  Coco/R itself) does not fall under the GNU General Public License.
-------------------------------------------------------------------------*/
#ifndef  COCO_XMLSPEC_H
#define  COCO_XMLSPEC_H

#ifndef  COCO_OBJECT_H
#include  "Object.h"
#endif

#ifndef  COCO_BITARRAY_H
#include  "BitArray.h"
#endif

#ifndef  COCO_ARRAYLIST_H
#include  "ArrayList.h"
#endif

EXTC_BEGIN

struct CcXmlSpec_s {
    CcObject_t base;

    CcGlobals_t * globals;
    CcsBool_t caseSensitive;
    CcBitArray_t options;
    CcArrayList_t Tags;
    CcArrayList_t Attrs;
    CcArrayList_t PInstructions;
};

CcXmlSpec_t * CcXmlSpec(CcGlobals_t * globals);

void CcXmlSpec_SetCaseSensitive(CcXmlSpec_t * self, CcsBool_t caseSensitive);
void CcXmlSpec_SetOption(CcXmlSpec_t * self, const CcsToken_t * token);
void CcXmlSpec_AddTag(CcXmlSpec_t * self, const char * tokenName,
		      const CcsToken_t * token);
void CcXmlSpec_AddAttr(CcXmlSpec_t * self, const char * tokenName,
		       const CcsToken_t * token);
void
CcXmlSpec_AddProcessInstruction(CcXmlSpec_t * self, const char * tokenName,
				const CcsToken_t * token);

void
CcXmlSpec_MakeTerminals(const CcXmlSpec_t * self, CcGlobals_t * globals);

typedef struct {
    char * name;
    int kind0;
    int kind1;
}  CcXmlSpecData_t;

CcXmlSpecData_t *
CcXmlSpec_GetSortedTagList(const CcXmlSpec_t * self,
			   const CcGlobals_t * globals, size_t * retNum);
CcXmlSpecData_t *
CcXmlSpec_GetSortedAttrList(const CcXmlSpec_t * self,
			    const CcGlobals_t * globals, size_t * retNum);
CcXmlSpecData_t *
CcXmlSpec_GetSortedPIList(const CcXmlSpec_t * self,
			  const CcGlobals_t * globals, size_t * retNum);

void CcXmlSpecData_Destruct(CcXmlSpecData_t * self, size_t num);

EXTC_END

#endif /* COCO_XMLSPEC_H */
